﻿namespace XExcel.Validations
{
    public class NotNullValidate : Validate
    {
        public static IValidate Default = new NotNullValidate();
        public NotNullValidate(string message = null)
        {
            Message = message ?? "不能为空";
        }

        public override bool Test(object val)
        {
            if(val == null)
            {
                return false;
            }
            if(val is string str && string.IsNullOrWhiteSpace(str))
            {
                return false;
            }
            return true;
        }
    }
}
